/* import Vue from 'vue'
import router from '@/router'
import store from '@/store' */

/**
 * 获取uuid
 */
export function getUUID () {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
    return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  })
}

/**
 * 日期格式化
 * @param date
 * @param formatter
 * @returns {*}
 */
export function formatterDate (date, formatter) {
  var o = {
    'M+': date.getMonth() + 1,                 // 月份
    'd+': date.getDate(),                    // 日
    'h+': date.getHours(),                   // 小时
    'm+': date.getMinutes(),                 // 分
    's+': date.getSeconds(),                 // 秒
    'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
    'S': date.getMilliseconds()             // 毫秒
  }
  if (/(y+)/.test(formatter)) { formatter = formatter.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) }
  for (var k in o) {
    if (new RegExp('(' + k + ')').test(formatter)) { formatter = formatter.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) }
  }
  return formatter
}

/**
 * 是否有权限
 * @param {*} key
 */
export function hasPermission (permission) {
  let permissionList = JSON.parse(sessionStorage.getItem('userPermission'))
  let index = -1
  if (typeof permission === 'object') {
    if (permission.length > 1) {
      for (let i = 0; i < permission.length; i++) {
        index = permissionList.indexOf(permission[i])
        if (index !== -1) {
          break
        }
      }
    } else {
      index = permissionList.indexOf(permission[0])
    }
  }
  return index !== -1
}

export function getSchoolType () {
  let that = this
  that.axios.get(that.$http.httpUrl('/api/pagination'), {
    params: {
      'sqlId': 'system.dict.get',
      'type': 'school_type'
    }
  }).then(function (response) {
    that.schoolTypeLst = response.data.data
  })
}

export function getGradeType () {
  let that = this
  that.axios.get(that.$http.httpUrl('/api/pagination'), {
    params: {
      'sqlId': 'system.dict.get',
      'type': 'school_type'
    }
  }).then(function (response) {
    that.schoolTypeLst = response.data.data
  })
}

export function getUserInfo () {
  return JSON.parse(sessionStorage.getItem('userInfo'))
}

export function getUserId () {
  let userInfo = getUserInfo()
  return userInfo.id
}

/**
 * 树形数据转换
 * @param {*} data
 * @param {*} id
 * @param {*} pid
 */
export function treeDataTranslate (data, id = 'id', pid = 'parent_id') {
  var res = []
  var temp = {}
  for (var i = 0; i < data.length; i++) {
    temp[data[i][id]] = data[i]
  }
  for (var k = 0; k < data.length; k++) {
    if (temp[data[k][pid]] && data[k][id] !== data[k][pid]) {
      if (!temp[data[k][pid]]['children']) {
        temp[data[k][pid]]['children'] = []
      }
      if (!temp[data[k][pid]]['_level']) {
        temp[data[k][pid]]['_level'] = 1
      }
      data[k]['_level'] = temp[data[k][pid]]._level + 1
      temp[data[k][pid]]['children'].push(data[k])
    } else {
      res.push(data[k])
    }
  }
  return res
}

/**
 * 清除登录信息
 */
export function clearLoginInfo () {
  sessionStorage.removeItem('userInfo')
  sessionStorage.removeItem('token')
  sessionStorage.removeItem('permissionList')
  // Vue.cookie.delete('token')
  // store.commit('resetStore')
  // router.options.isAddDynamicMenuRoutes = false
}
